<template>
	<view>
		<view class="contentView flex-row-space-between">
			<view class="dsr" style="margin-left: 1rpx;">
				补充委托书
			</view>
			<image @click="isShowClick" style="width: 28rpx;height: 28rpx;margin-top: 40rpx;" src="/static/my/mine_blackdownarrow.png"></image>
		</view>
		<view v-if="isShow">
			<view class="contentView flex-row-space-between" style="margin-top: 20rpx;">
				<view class="name">
					法律文书送达地址
				</view>
				<input @input="textInput" :disabled="isEdit" v-model="infoDic.entrustaddress" class="inputView" placeholder="请输入"/>
			</view>
			<picker :disabled="isEdit" mode="date" :value="date" :start="startDate" @change="bindDateChange">
				<view class="contentView flex-row-space-between" style="margin-top: 20rpx;">
					<view class="name">
						委托期限至
					</view>
					<input @input="textInput" disabled="true" v-model="infoDic.entrustdate" class="inputView" placeholder="请选择"/>
					为止
				</view>
			</picker>
			
		</view>
	</view>
</template>

<script>
	export default {
		name:"buChongWeiTuoShu",
		props: {
			//当前组件内容信息
			infoDic: {
				type: Object,
				default: function() {
					return {
						entrustaddress: '',
						entrustdate: ''
					};
				}
			},
			//当前组件是否可编辑
			isEdit: {
				type: Boolean,
				default: false,
			},
		},
		data() {
			const currentDate = this.getDate({format: true})
			return {
				isShow:false,
				date: currentDate,
				startDate:currentDate,
			};
		},
		methods:{
			isShowClick(){
				this.isShow = !this.isShow
			},
			textInput(){
				console.log('this.infoDic----',this.infoDic)
				this.$emit('buChongWeiTuoShuInfoCallBack', this.infoDic)
			},
			bindDateChange(e){
				console.log('e-----------',e)
				this.date = e.detail.value
				this.infoDic.entrustdate = e.detail.value
				this.textInput()
			},
			 getDate(type) {
				const date = new Date();
			    let year = date.getFullYear();
			    let month = date.getMonth() + 1;
			    let day = date.getDate();
						
			    if (type === 'start') {
			        year = year - 60;
			    } else if (type === 'end') {
			        year = year + 2;
			    }
			    month = month > 9 ? month : '0' + month;
			    day = day > 9 ? day : '0' + day;
			    return `${year}-${month}-${day}`;
			}
		}
	}
</script>

<style>
	.inputView{
		width: 340rpx;
		margin-left: 12rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 30rpx;
		color: #333333;
		text-align: right;
	}
	.name{
		width: 250rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 30rpx;
		color: #333333;
	}
	.contentView{
		padding-left: 24rpx;
		padding-right: 24rpx;
		padding-top: 20rpx;
		padding-bottom: 20rpx;
	}
	.dsr{
		margin-left: 24rpx;
		margin-top: 40rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: bold;
		font-size: 32rpx;
		color: #333333;
	}
</style>